load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")
load("//fboss/qsfp_service:qsfp_service.bzl", "QSFP_COMMON_COMPILER_FLAGS")

oncall("fboss_optics_phy")

cpp_library(
    name = "qsfp-module",
    srcs = [
        "QsfpHelper.cpp",
        "QsfpModule.cpp",
        "QsfpUtil.cpp",
        "cmis/CmisFieldInfo.cpp",
        "cmis/CmisModule.cpp",
        "cmis/facebook/CmisModule.cpp",
        "facebook/QsfpModule.cpp",
        "facebook/SffModule.cpp",
        "sff/Sff8472FieldInfo.cpp",
        "sff/Sff8472Module.cpp",
        "sff/SffFieldInfo.cpp",
        "sff/SffModule.cpp",
    ],
    headers = [
        "QsfpFieldInfo.h",
        "QsfpUtil.h",
        "cmis/CmisFieldInfo.h",
        "cmis/CmisHelper.h",
        "cmis/CmisModule.h",
        "facebook/SffFr1FieldInfo.h",
        "sff/Sff8472FieldInfo.h",
        "sff/Sff8472Module.h",
        "sff/SffFieldInfo.h",
        "sff/SffModule.h",
    ],
    compiler_flags = QSFP_COMMON_COMPILER_FLAGS,
    exported_deps = [
        "fbsource//third-party/re2:re2",
        ":firmware_upgrader",
        "//common/strings/icu:icu_string",
        "//common/time:time",
        "//fboss/agent:fboss-error",
        "//fboss/agent:fboss-types",
        "//fboss/agent:switch_config-cpp2-types",
        "//fboss/lib/firmware_storage:firmware_storage",
        "//fboss/lib/link_snapshots:async_filewriter_factory",
        "//fboss/lib/link_snapshots:snapshot_manager",
        "//fboss/lib/phy:phy-cpp2-types",
        "//fboss/lib/phy:prbs-cpp2-types",
        "//fboss/lib/usb:i2-api",
        "//fboss/qsfp_service:stats",
        "//fboss/qsfp_service:transceiver-manager",
        "//fboss/qsfp_service/if:config-cpp2-types",
        "//fboss/qsfp_service/if:transceiver-cpp2-types",
        "//fboss/qsfp_service/lib:qsfp-config-parser-helper",
        "//fboss/qsfp_service/lib:qsfp-service-client",
        "//fboss/qsfp_service/module/cmis:cmis-cpp2-types",
        "//fboss/qsfp_service/module/sff:sff-cpp2-types",
        "//fboss/qsfp_service/module/sff:sff8472-cpp2-types",
        "//folly:format",
        "//folly:synchronized",
        "//folly/executors:function_scheduler",
        "//folly/futures:core",
        "//folly/io:iobuf",
        "//folly/io/async:async_base",
        "//folly/logging:logging",
        "//thrift/lib/cpp/util:enum_utils",
    ],
    exported_external_deps = [
        ("boost", None, "boost_algorithm"),
        ("boost", None, "boost_bimap"),
    ],
)

cpp_library(
    name = "firmware_upgrader",
    srcs = [
        "CdbCommandBlock.cpp",
        "FirmwareUpgrader.cpp",
    ],
    headers = [
        "CdbCommandBlock.h",
        "FirmwareUpgrader.h",
        "Transceiver.h",
        "TransceiverImpl.h",
    ],
    compiler_flags = QSFP_COMMON_COMPILER_FLAGS,
    exported_deps = [
        "//fboss/agent:fboss-error",
        "//fboss/agent:fboss-types",
        "//fboss/agent:switch_config-cpp2-types",
        "//fboss/agent/if:ctrl-cpp2-types",
        "//fboss/lib/firmware_storage:firmware_storage",
        "//fboss/lib/phy:phy-cpp2-types",
        "//fboss/lib/phy:prbs-cpp2-types",
        "//fboss/lib/usb:transceiver_access_parameter",
        "//fboss/qsfp_service/if:config-cpp2-types",
        "//fboss/qsfp_service/if:port_state-cpp2-types",
        "//fboss/qsfp_service/if:transceiver-cpp2-types",
        "//fboss/qsfp_service/module/cmis:cmis-cpp2-types",
        "//folly:conv",
        "//folly:file",
        "//folly:file_util",
        "//folly:format",
        "//folly:string",
        "//folly/futures:core",
        "//folly/init:init",
        "//folly/io:iobuf",
        "//folly/io/async:async_base",
        "//folly/logging:logging",
    ],
    exported_external_deps = [
        "glog",
    ],
)

cpp_library(
    name = "i2c_log_buffer",
    srcs = [
        "I2cLogBuffer.cpp",
    ],
    headers = [
        "I2cLogBuffer.h",
    ],
    compiler_flags = QSFP_COMMON_COMPILER_FLAGS,
    exported_deps = [
        "//fboss/lib/usb:transceiver_access_parameter",
        "//fboss/qsfp_service/if:config-cpp2-types",
        "//fboss/qsfp_service/module/cmis:cmis-cpp2-types",
        "//fboss/qsfp_service/module/sff:sff-cpp2-types",
        "//fboss/qsfp_service/module/sff:sff8472-cpp2-types",
        "//folly:file_util",
        "//folly:string",
        "//folly/logging:logging",
    ],
)
